<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>遍历对象</title>
</head>

<body>
    <script>
        // 遍历对象
        var obj = {
            name: '路飞',
            age: 18,
            sex: '男',
            fn: function() {

            }
        }
        console.log(obj.name);
        console.log(obj['age']);

        // for in 遍历对象
        // for(变量 in 对象){}
        // for in 推荐写k key的意思

        for (var k in obj) {
            console.log(k) // k 输出变量 得到的是 *属性名
            console.log(obj[k]) // obj[k] 得到的是 *属性值
        }
    </script>
</body>

</html>